﻿@{
    ViewBag.Title = "home";
    var game_max_marine = ViewData["marine"] as IEnumerable<Result>;
    var game_max_mineral = ViewData["mineral"] as IEnumerable<Result>;
    var game_max_maurader = ViewData["maurader"] as IEnumerable<Result>; 
}

@Html.ActionLink("to list of all results","../Result")<br />
@Html.ActionLink("to search all results","../Result/Search")<br />
@{   
string [] max_search = new string[3] {"mineral", "marine", "maurader"};
IEnumerable<Result>[] max_search_objs = new IEnumerable<Result>[3] { game_max_mineral, game_max_marine, game_max_maurader };
int i = 0;
int counter = 0;
}
<table id="hometbl">
        @for (i = 0; i < 3; i++)
        {
            <tr>
            <td>@Html.Raw("max " + max_search[i] + " games: ")</td>
            @if (max_search_objs[i].Any())
            {
                counter = 0;
                <td> </td>
                foreach (Result r in max_search_objs[i])
                {
                    counter++;
                    <td>
                    @if (counter < 5)
                    {    
                        @Html.ActionLink(r.GameId.ToString(), "../Result/Details", new { id = r.GameId })
                    }
                    
                    @if (max_search_objs[i].Count() >= 5 && counter >= 5)
                    {
                        ViewData["max"] = max_search[i];
                        ViewData["marine"] = game_max_marine;
                        ViewData["maurader"] = game_max_maurader;
                        ViewData["mineral"] = game_max_mineral;
                        @Html.ActionLink(" all", "../Result/More", new { search_unit = max_search[i] })
                        break;
                    }
                    </td>
                }
            }
        </tr>
}
</table>
